﻿using System;
using System.Collections.Generic;
using GeoAPI.Geometries;

namespace NetTopologySuite.Operation.Overlay.Validate
{
	internal class PolygonalLineworkExtracter : IGeometryFilter
	{
		public PolygonalLineworkExtracter()
		{
			this._linework = new List<ILineString>();
		}

		public void Filter(IGeometry g)
		{
			if (g is IPolygon)
			{
				IPolygon polygon = (IPolygon)g;
				this._linework.Add(polygon.ExteriorRing);
				for (int i = 0; i < polygon.NumInteriorRings; i++)
				{
					this._linework.Add(polygon.InteriorRings[i]);
				}
			}
		}

		public List<ILineString> Linework
		{
			get
			{
				return this._linework;
			}
		}

		private readonly List<ILineString> _linework;
	}
}
